<div class="problemindexholder" problemindex="B">
 <div class="ttypography">
  <div class="problem-statement">
   <div class="header">
    <div class="title">
     B. Balanced Substring
    </div>
    <div class="time-limit">
     <div class="property-title">
      time limit per test
     </div>
     1 second
    </div>
    <div class="memory-limit">
     <div class="property-title">
      memory limit per test
     </div>
     256 megabytes
    </div>
    <div class="input-file">
     <div class="property-title">
      input
     </div>
     standard input
    </div>
    <div class="output-file">
     <div class="property-title">
      output
     </div>
     standard output
    </div>
   </div>
   <div>
    <p>
     You are given a string
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     consisting only of characters
     <span class="tex-font-style-tt">
      0
     </span>
     and
     <span class="tex-font-style-tt">
      1
     </span>
     . A substring
     <span class="tex-span">
      [
      <i>
       l
      </i>
      ,
      <i>
       r
      </i>
      ]
     </span>
     of
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     is a string
     <span class="tex-span">
      <i>
       s
      </i>
      <sub class="lower-index">
       <i>
        l
       </i>
      </sub>
      <i>
       s
      </i>
      <sub class="lower-index">
       <i>
        l
       </i>
       + 1
      </sub>
      <i>
       s
      </i>
      <sub class="lower-index">
       <i>
        l
       </i>
       + 2
      </sub>
      ...
      <i>
       s
      </i>
      <sub class="lower-index">
       <i>
        r
       </i>
      </sub>
     </span>
     , and its length equals to
     <span class="tex-span">
      <i>
       r
      </i>
      -
      <i>
       l
      </i>
      + 1
     </span>
     . A substring is called
     <span class="tex-font-style-it">
      balanced
     </span>
     if the number of zeroes (
     <span class="tex-font-style-tt">
      0
     </span>
     ) equals to the number of ones in this substring.
    </p>
    <p>
     You have to determine the length of the longest
     <span class="tex-font-style-it">
      balanced
     </span>
     substring of
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     .
    </p>
   </div>
   <div class="input-specification">
    <div class="section-title">
     Input
    </div>
    <p>
     The first line contains
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     (
     <span class="tex-span">
      1 ≤
      <i>
       n
      </i>
      ≤ 100000
     </span>
     ) — the number of characters in
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     .
    </p>
    <p>
     The second line contains a string
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     consisting of exactly
     <span class="tex-span">
      <i>
       n
      </i>
     </span>
     characters. Only characters
     <span class="tex-font-style-tt">
      0
     </span>
     and
     <span class="tex-font-style-tt">
      1
     </span>
     can appear in
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     .
    </p>
   </div>
   <div class="output-specification">
    <div class="section-title">
     Output
    </div>
    <p>
     If there is no non-empty
     <span class="tex-font-style-it">
      balanced
     </span>
     substring in
     <span class="tex-span">
      <i>
       s
      </i>
     </span>
     , print
     <span class="tex-font-style-tt">
      0
     </span>
     . Otherwise, print the length of the longest
     <span class="tex-font-style-it">
      balanced
     </span>
     substring.
    </p>
   </div>
   <div class="sample-tests">
    <div class="section-title">
     Examples
    </div>
    <div class="sample-test">
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>8<br/>11010111<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>4<br/></pre>
     </div>
     <div class="input">
      <div class="title">
       Input
      </div>
      <pre>3<br/>111<br/></pre>
     </div>
     <div class="output">
      <div class="title">
       Output
      </div>
      <pre>0<br/></pre>
     </div>
    </div>
   </div>
   <div class="note">
    <div class="section-title">
     Note
    </div>
    <p>
     In the first example you can choose the substring
     <span class="tex-span">
      [3, 6]
     </span>
     . It is
     <span class="tex-font-style-it">
      balanced
     </span>
     , and its length is
     <span class="tex-span">
      4
     </span>
     . Choosing the substring
     <span class="tex-span">
      [2, 5]
     </span>
     is also possible.
    </p>
    <p>
     In the second example it's impossible to find a non-empty
     <span class="tex-font-style-it">
      balanced
     </span>
     substring.
    </p>
   </div>
  </div>
  <p>
  </p>
 </div>
</div>
